<?php
/* [$WindsForce] (C)Hunzhiwange.COM Since 2012.03.17.
   家居商家订单控制器($小牛New $2014.07.28)*/

!defined('Q_PATH') && exit;

class JiajuorderController extends AController{

	public function init__(){
		$this->_arrNotMethod=array(
			'save_previewstatus',
			'save_preview',
			'view_preview',
			'foreverdelete_deep',
			'input_change_ajax',
			'input_change_unique',
			'forbid',
			'openitem',
			'clear_recycle',
			'save_sort',
			'insert',
			'add',
			'edit',
			'update'
		);
		
		parent::init__();
	}
	
	public function filter_(&$arrMap){
		$arrMap['A.jiajuorder_realname']=array('like',"%".Q::G('jiajuorder_realname')."%");
		$arrMap['A.jiajuorder_realspace']=array('egt',intval(Q::G('jiajuorder_realspace')));
		$arrMap['A.jiajuorder_qq']=array('like',"%".Q::G('jiajuorder_qq')."%");
		$arrMap['A.jiajuorder_mobile']=array('like',"%".Q::G('jiajuorder_mobile')."%");
		$arrMap['A.jiajuorder_biddingcode']=array('like',"%".Q::G('jiajuorder_biddingcode')."%");
		$arrMap['A.jiajucompany_id']=$GLOBALS['_company_']['jiajucompany_id'];

		// 添加时间
		$this->getTime_('A.create_dateline',$arrMap);

		$nJiajuorderSpaceid=Q::G('jiajuorder_spaceid');
		if($nJiajuorderSpaceid!==null && $nJiajuorderSpaceid!=''){
			$arrMap['A.jiajuorder_spaceid']=$nJiajuorderSpaceid;
		}
		
		$nJiajuorderType=Q::G('jiajuorder_type');
		if($nJiajuorderType!==null && $nJiajuorderType!=''){
			$arrMap['A.jiajuorder_type']=$nJiajuorderType;
		}
	}
	
	protected function sqljoin_(){
		return "->joinLeft('".Q::C('DB_PREFIX')."jiajucompanyclass AS B','B.jiajucompanyclass_name AS space_name','A.jiajuorder_spaceid=B.jiajucompanyclass_id')";
	}

	public function bIndex_(){
		$oJiajucompanyclass=Q::instance('JiajucompanyclassModel');
		$this->assign('arrSpaces',$oJiajucompanyclass->getClass(53));
	}

	public function orderStatus($status){
		switch($status){
			case 0:// 客户下单
				return '<span style="color:blue;">等待确认</span>';
				break;
			case 1:// 商家确认
				return '<span style="color:#0DD07F;">商家已确认</span>';
				break;
			case 13:
				return '<span style="color:gray;">订单关闭</span>';
				break;
			default:
				return '未知';
				break;
		}
	} 

}
